<?php
declare (strict_types = 1);

namespace app\model;

use think\Model;
use think\model\relation\HasMany;

/**
 * @mixin \think\Model
 */
class AdminTeachingBuilding extends Model
{
    //
    protected $autoWriteTimestamp = true;

    public function school() {
        return $this->belongsTo(AdminSchool::class, 'school_id')->bind([
            'school_name' => 'name'
        ]);
    }

    public function classroom(): hasMany {
        return $this->hasMany('AdminClassroom', 'building_id', 'id')
            ->where('is_delete', 0)
            ->field('id,building_id,name classroom_name');
    }
}
